Compute Flow Direction at Powell Butte, OR


In [1]:
%matplotlib inline
import numpy
import matplotlib.pyplot as plt
import matplotlib.colors as mcolor

import watershed

Load an plot the raw data


In [2]:
pb = watershed.load_example('powell_butte') * 1000
fig, ax = plt.subplots(figsize=(6,6))
img = ax.imshow(pb, interpolation='none', cmap=plt.cm.Blues_r, vmax=120)
fig.colorbar(img)


Out[2]:
<matplotlib.colorbar.Colorbar instance at 0x000000000A60EF08>

Compute flow direction


In [3]:
flow_dir = watershed.flow_direction_d8(pb)`


bounds = sorted(watershed.algo.DIR_MAP.values())
cmap = plt.cm.Set1_r
norm = mcolor.BoundaryNorm(bounds, cmap.N)
fig, ax = plt.subplots(figsize=(6,6))
img = ax.imshow(flow_dir, interpolation='none', cmap=cmap, norm=norm)
fig.colorbar(img)


Out[3]:
<matplotlib.colorbar.Colorbar instance at 0x00000000128A8508>